# decoding:utf-8
import functools

from flask import session, current_app, g




def do_index_class(index):
    """
    如果index == 1 first, 2 second, 3 third  ""
    :param index:被过滤的参数
    :return:
    """
    if index == 1:
        return 'first'
    elif index ==2:
        return 'second'
    elif index ==3 :
        return 'third'
    else:
        return ""

def user_longin_data(func):
    @functools.wraps(func)
    def wrapper(*args,**kwargs):
        user_id = session.get('user_id')
        user = None
        if user_id:
            try:
                from Info.models import User
                user = User.query.get(user_id)

            except Exception as e:
                current_app.logger.error(e)
        g.user = user
        return func(*args,**kwargs)
    return wrapper